<template>
  <el-dialog
    width="80%"
    @open="handleOpen"
    @close="handleClose"
    title="详情"
    :visible="dialogVisible"
  >
    <el-form :model="detailData" label-width="120px" label-position="left">
      <h1>请求信息</h1>
      <el-row>
        <el-col :span="8">
          <el-form-item label="发起人">
            {{ detailData.user.nickName }}
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="房东">
            {{ detailData.house.user.nickName }}
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="状态">
            {{ detailData.status | askStatusFilter }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="期望租金">
            {{ detailData.rent }}
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="开始时间">
            {{ detailData.startTime | timeFilter }}
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="结束时间">
            {{ detailData.endTime | timeFilter }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="原因">
            {{ detailData.reason }}
          </el-form-item>
        </el-col>
      </el-row>
      <h1>房屋信息</h1>
      <el-row>
        <el-col :span="8">
          <el-form-item label="房屋名">
            {{ detailData.house.name }}
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="房屋地址">
            {{ detailData.house.address }}
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="所在地区">
            {{ detailData.house.area.name }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="创建时间">
            {{ detailData.house.createdAt | timeFilter }}
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="房屋状态">
            {{
              detailData.house.status == 1
                ? "下架"
                : detailData.house.status == 2
                ? "上架"
                : detailData.house.status == 3
                ? "已出租"
                : "暂存"
            }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="租金">
            {{ detailData.house.rent }}
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="是否是学区房">
            {{ detailData.house.isSchool ? "是" : "否" }}
          </el-form-item>
        </el-col>
        <el-col :span="8" v-if="detailData.house.isSchool">
          <el-form-item label="所在学区">
            {{ detailData.house.schoolName }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="相关描述">
            {{ detailData.house.description }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="相关图片">
            <el-image
              v-for="item in detailData.house.imgs.split(',')"
              :key="item"
              style="width: 100px; height: 100px"
              :src="item"
            ></el-image>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer">
      <el-button @click="handleClose">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import detailDialog from "../../../mixins/detailDialog";

export default {
  name: "detailDialog",
  mixins: [detailDialog],
  data() {
    return {
      detailData: {
        status: "",
        rent: "",
        startTime: "",
        endTime: "",
        reason: "",
        house: {
          imgs: "",
          area: {},
          user: {}
        },
        user: {}
      },
      getDetailUrl: "/api/ask/ask"
    };
  }
};
</script>

<style scoped></style>
